#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int arr[5000][5000] = { 0 };
int main()
{
    int m, n;
    scanf("%d %d", &m, &n);

    int i = 0;
    int j = 0;
    for (i; i < m; i++)
    {
        for (j = 0; j < n; j++)
            scanf("%d", &arr[i][j]);
    }
    int Maxnum = -1;
    int Maxsize = 0;
    int now = -1;
    int num = 1;
    for (i = 0; i < m; i++)
    {

        if (i % 2 == 0)
        {
            for (j = 0; j < n; j++)
            {
                if (now == arr[i][j])
                {
                    num++;
                }
                else
                {
                    if (Maxsize < num)
                    {
                        Maxsize = num;
                        Maxnum = now;
                    }
                    num = 1;
                    now = arr[i][j];
                }

            }
        }
        else
        {
            for (j = n - 1; j > -1; j--)
            {
                if (now == arr[i][j])
                {
                    num++;
                }
                else
                {
                    if (Maxsize < num)
                    {
                        Maxsize = num;
                        Maxnum = now;
                    }
                    num = 1;
                    now = arr[i][j];
                }

            }

        }
        if (num > Maxsize) {
            Maxnum = now;
            Maxsize = num;
        }

    }
    if (Maxsize == 1)
        Maxnum = arr[0][0];
    printf("(%d,%d)", Maxnum, Maxsize);
    return 0;
}